﻿using System;
using System.Threading;

namespace Ns.Threading
{
    /// <summary>
    /// Enables the operating system to wait for <see cref="Timer"/> disposing.
    /// </summary>
    /// <seealso href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/a54102ad-839b-45a8-9bf3-67aaa5ca053d/">Correct disposal of System.Threading.Timer</seealso>
    internal class InvalidWaitHandle : WaitHandle
    {
        [Obsolete("Use the SafeWaitHandle property instead.")]
        public override IntPtr Handle
        {
            get
            {
                return WaitHandle.InvalidHandle;
            }
            set
            {
                throw new InvalidOperationException();
            }
        }
    }
}
